<template>
  <el-card class="menuManagement">
    <el-tree
      :data="data"
      show-checkbox
      node-key="id"
      :props="defaultProps"
      ref="tree"
      accordion
      @check-change="getChecked"
    ></el-tree>
    <div class="boxBtn">
      <el-button type="primary" @click="permitSetMenu">同步</el-button>
    </div>

    <!-- <h4>已有权限:</h4>
    <div class="echoListBox">
      <p v-for="(i, index) in echoList" :key="index">
        <span>{{ i.displayname }}</span>
      </p>
    </div> -->
  </el-card>
</template>

<script>
// import { permitSetMenu, permitMenu } from "@/api/account.js"; //后台设置保存菜单
// import { log } from "video.js";

export default {
  inject: ["reload"],
  data() {
    return {
      data: [
        //数据管理
        {
          path: "/",
          component: Layout,
          redirect: "/DataAnalysis/UserAnalysis",
          name: "DataAnalysis",
          alwaysShow: true,
          meta: {
            title: "数据管理",
            icon: "dataAnalysis",
          },
          children: [
            {
              path: "/DataAnalysis/UserAnalysis",
              name: "UserAnalysis",
              component: () => import("@/views/DataAnalysis/UserAnalysis"),
              meta: {
                title: "用户分析",
              },
              hidden: false,
            },
            {
              path: "/DataAnalysis/FlowAnalysis",
              name: "FlowAnalysis",
              component: () => import("@/views/DataAnalysis/FlowAnalysis"),
              meta: {
                title: "流水分析",
              },
              hidden: false,
            },
            {
              path: "/DataAnalysis/CallAnalysis",
              name: "CallAnalysis",
              component: () => import("@/views/DataAnalysis/CallAnalysis"),
              meta: {
                title: "通话分析",
              },
              hidden: false,
            },
            {
              path: "/DataAnalysis/ChannelAnalysis",
              name: "ChannelAnalysis",
              component: () => import("@/views/DataAnalysis/ChannelAnalysis"),
              meta: {
                title: "渠道分析",
              },
              hidden: false,
            },
            {
              path: "/DataAnalysis/EventAnalysis",
              name: "EventAnalysis",
              component: () => import("@/views/DataAnalysis/EventAnalysis"),
              meta: {
                title: "事件分析",
              },
              hidden: false,
            },
            {
              path: "/DataAnalysis/MonetaryAnalysis",
              name: "MonetaryAnalysis",
              component: () => import("@/views/DataAnalysis/MonetaryAnalysis"),
              meta: {
                title: "货币分析",
              },
              hidden: false,
            },
            {
              path: "/DataAnalysis/BuryList",
              name: "BuryList",
              component: () => import("@/views/DataAnalysis/BuryList"),
              meta: {
                title: "埋点列表",
              },
              hidden: false,
            },
            // {
            //   path: '/ApplicationManagement/ApplicationManagementDetails',
            //   name: 'ApplicationManagementDetails',
            //   component: () => import('@/views/ApplicationManagement/ApplicationManagementDetails'),
            //   meta: { title: '应用管理列表详情', GuidePath: true, JumpPath: "/ApplicationManagement/ApplicationManagementList" },
            //   hidden: true
            // },
          ],
        },
        //用户管理
        {
          path: "/UserManagement",
          component: Layout,
          redirect: "/UserManagement/UserManagementList",
          name: "UserManagement",
          alwaysShow: true,
          meta: {
            title: "用户管理",
            icon: "userB",
          },
          children: [
            {
              path: "/UserManagement/UserManagementList",
              name: "UserManagementList",
              component: () =>
                import("@/views/UserManagement/UserManagementList"),
              meta: {
                title: "用户列表",
              },
              hidden: false,
            },
            {
              path: "/UserManagement/VipUserList",
              name: "VipUserList",
              component: () => import("@/views/UserManagement/VipUserList"),
              meta: {
                title: "VIP用户列表",
              },
              hidden: false,
            },
            {
              path: "/UserManagement/UserDetailsList",
              name: "UserDetailsList",
              component: () => import("@/views/UserManagement/UserDetailsList"),
              meta: {
                title: "用户详情",
              },
              hidden: false,
            },
          ],
        },

        //审核管理
        {
          path: "/AuditManagement",
          component: Layout,
          redirect: "/AuditManagement/AuditManagementList",
          name: "AuditManagement",
          alwaysShow: true,
          meta: {
            title: "审核管理",
            icon: "shenhe",
          },
          children: [
            {
              path: "/AuditManagement/RechargeAuditList",
              name: "RechargeAuditList",
              component: () =>
                import("@/views/AuditManagement/RechargeAuditList"),
              meta: {
                title: "充值审核",
              },
              hidden: false,
            },
            {
              path: "/AuditManagement/WithdrawalAuditList",
              name: "WithdrawalAuditList",
              component: () =>
                import("@/views/AuditManagement/WithdrawalAuditList"),
              meta: {
                title: "提现审核",
              },
              hidden: false,
            },
            {
              path: "/AuditManagement/DataReviewList",
              name: "DataReviewList",
              component: () => import("@/views/AuditManagement/DataReviewList"),
              meta: {
                title: "资料审核",
              },
              hidden: false,
            },
            {
              path: "/AuditManagement/ReportReview",
              name: "ReportReview",
              component: () => import("@/views/AuditManagement/ReportReview"),
              meta: {
                title: "举报审核",
              },
              hidden: false,
            },
            {
              path: "/AuditManagement/Reviewed",
              name: "Reviewed",
              component: () => import("@/views/AuditManagement/Reviewed"),
              meta: {
                title: "举报详情",
                GuidePath: true,
                JumpPath: "/AuditManagement/ReportReview",
              },
              hidden: true,
            },
          ],
        },
        //运营管理
        {
          path: "/OperationManagement",
          component: Layout,
          redirect: "/OperationManagement/PaymentSettings",
          name: "OperationManagement",
          alwaysShow: true,
          meta: {
            title: "运营管理",
            icon: "yunying",
          },
          children: [
            {
              path: "/OperationManagement/PaymentSettings",
              name: "PaymentSettings",
              component: () =>
                import("@/views/OperationManagement/PaymentSettings"),
              meta: {
                title: "充值提现管理",
              },
              hidden: false,
            },
            {
              path: "/OperationManagement/ReputationManagement",
              name: "ReputationManagement",
              component: () =>
                import("@/views/OperationManagement/ReputationManagement"),
              meta: {
                title: "信誉值管理",
              },
              hidden: false,
            },
            {
              path: "/OperationManagement/Blockeywords",
              name: "Blockeywords",
              component: () =>
                import("@/views/OperationManagement/Blockeywords"),
              meta: {
                title: "屏蔽关键词",
              },
              hidden: false,
            },
            {
              path: "/OperationManagement/GemstoneTaskManagement",
              name: "GemstoneTaskManagement",
              component: () =>
                import("@/views/OperationManagement/GemstoneTaskManagement"),
              meta: {
                title: "宝石任务管理",
              },
              hidden: false,
            },
          ],
        },
        //通知管理
        {
          path: "/NotificationManagement",
          component: Layout,
          redirect: "/NotificationManagement/NotificationManagementList",
          name: "NotificationManagement",
          alwaysShow: true,
          meta: {
            title: "通知管理",
            icon: "tongzhiguanli",
          },
          children: [
            {
              path: "/NotificationManagement/NotificationManagementList",
              name: "NotificationManagementList",
              component: () =>
                import(
                  "@/views/NotificationManagement/NotificationManagementList"
                ),
              meta: {
                title: "系统消息",
              },
              hidden: false,
            },
            {
              path: "/NotificationManagement/UserFeedback",
              name: "UserFeedback",
              component: () =>
                import("@/views/NotificationManagement/UserFeedback"),
              meta: {
                title: "用户反馈列表",
              },
              hidden: false,
            },
            {
              path: "/NotificationManagement/FeedbackDetails",
              name: "FeedbackDetails",
              component: () =>
                import("@/views/NotificationManagement/FeedbackDetails"),
              meta: {
                title: "反馈详情",
                GuidePath: true,
                JumpPath: "/NotificationManagement/UserFeedback",
              },
              hidden: true,
            },
          ],
        },
        //系统管理
        {
          path: "/SystemManagement",
          component: Layout,
          redirect: "/SystemManagement/SystemManagementList",
          name: "SystemManagement",
          alwaysShow: true,
          meta: {
            title: "系统管理",
            icon: "guanli4",
          },
          children: [
            {
              path: "/SystemManagement/AdministratorManagement",
              name: "AdministratorManagement",
              component: () =>
                import("@/views/SystemManagement/AdministratorManagement"),
              meta: {
                title: "管理员管理",
              },
              hidden: false,
            },
            {
              path: "/SystemManagement/AdministratorLog",
              name: "AdministratorLog",
              component: () =>
                import("@/views/SystemManagement/AdministratorLog"),
              meta: {
                title: "管理员日志",
              },
              hidden: false,
            },
            {
              path: "/SystemManagement/MenuManagement",
              name: "MenuManagement",
              component: () =>
                import("@/views/SystemManagement/MenuManagement"),
              meta: {
                title: "权限管理",
              },
              hidden: false,
            },
          ],
        },
        {
          id: "home",
          label: "空",
          uri: "/login/home",
        },
      ],
      defaultProps: {
        children: "children",
        label: "label",
      },
      arr: [],

      echoList: [],
    };
  },
  methods: {
    getChecked(data) {
      this.arr.push(data);
      // console.log(data);
    },
    permitSetMenu() {
      permitSetMenu({
        menu: this.arr,
      }).then((res) => {
        if (res.code == 0) {
          this.$message({
            type: "success",
            message: "同步成功",
          });
          this.reload();
        }
      });
    },
    permitMenu() {
      permitMenu({}).then((res) => {
        if (res.code == 0) {
          this.echoList = res.data.list;
        }
      });
    },
  },
  created() {
    this.permitMenu();
  },
};
</script>

<style lang="less" scoped>